import request from './request'

// 获取角色列表
export function getRoleList() {
  return request({
    url: '/api/role',
    method: 'get'
  })
}

// 创建角色
export function createRole(data) {
  return request({
    url: '/api/role',
    method: 'post',
    data
  })
}

// 更新角色
export function updateRole(roleId, data) {
  return request({
    url: `/api/role/${roleId}`,
    method: 'put',
    data
  })
}

// 删除角色
export function deleteRole(roleId) {
  return request({
    url: `/api/role/${roleId}`,
    method: 'delete'
  })
}

// 切换角色状态
export function toggleRoleStatus(roleId, isActived) {
  const action = isActived ? 'disable' : 'enable'
  return request({
    url: `/api/role/${roleId}/${action}`,
    method: 'post'
  })
}

// 分配权限
export function assignPermissions(roleId, permissionId) {
  return request({
    url: `/api/role/${roleId}/assign-permission?permissionId=${permissionId}`,
    method: 'post'
  })
}

// 移除权限
export function removePermission(roleId, permissionId) {
  return request({
    url: `/api/role/${roleId}/remove-permission?permissionId=${permissionId}`,
    method: 'post'
  })
}

// 获取角色权限
export function getRolePermissions(roleId) {
  return request({
    url: `/api/role/${roleId}/permissions`,
    method: 'get'
  })
} 